//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  http://www.nopCommerce.com/License.aspx. 
// 
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
// See the License for the specific language governing rights and limitations under the License.
// 
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
// 
// Contributor(s): _______. 
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using Tathata.Common.Caching;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data;
using System.Globalization;
using Tathata.Common.DAL;
using Tathata.Common.BLL.Entities;
using Tathata.Common.BLL.EntityCollections;
using Tathata.Common.DAL.Managers;

namespace Tathata.Common.BLL.Managers
{
    /// <summary>
    /// Customer attribute manager
    /// </summary>
    public class CustomerAttributeManager
    {
        #region Methods
        /// <summary>
        /// Deletes a customer attribute
        /// </summary>
        /// <param name="CustomerAttributeID">Customer attribute identifier</param>
        public static void DeleteCustomerAttribute(int CustomerAttributeID)
        {
            CustomerAttributeDBManager.DeleteCustomerAttribute(CustomerAttributeID);
        }

        /// <summary>
        /// Gets a customer attribute
        /// </summary>
        /// <param name="CustomerAttributeID">Customer attribute identifier</param>
        /// <returns>A customer attribute</returns>
        public static CustomerAttribute GetByCustomerAttributeID(int CustomerAttributeID)
        {
            return CustomerAttributeDBManager.GetByCustomerAttributeID(CustomerAttributeID);
        }

        /// <summary>
        /// Gets a collection of customer attributes by customer identifier
        /// </summary>
        /// <param name="CustomerID">Customer identifier</param>
        /// <returns>Customer attributes</returns>
        public static CustomerAttributeCollection GetAllByCustomerID(int CustomerID)
        {
            return CustomerAttributeDBManager.GetAllByCustomerID(CustomerID);
        }

        /// <summary>
        /// Inserts a customer attribute
        /// </summary>
        /// <param name="CustomerID">Customer identifier</param>
        /// <param name="Key">An attribute key</param>
        /// <param name="Value">An attribute value</param>
        /// <returns>A customer attribute</returns>
        public static CustomerAttribute InsertCustomerAttribute(int CustomerID, string Key, string Value)
        {
            if (CustomerID == 0)
                throw new Exception("Cannot insert attribute for non existing customer");
            return CustomerAttributeDBManager.InsertCustomerAttribute(CustomerID, Key, Value);
        }

        /// <summary>
        /// Updates the customer attribute
        /// </summary>
        /// <param name="CustomerAttributeID">Customer attribute identifier</param>
        /// <param name="CustomerID">Customer identifier</param>
        /// <param name="Key">An attribute key</param>
        /// <param name="Value">An attribute value</param>
        /// <returns>A customer attribute</returns>
        public static CustomerAttribute UpdateCustomerAttribute(int CustomerAttributeID, int CustomerID, string Key, string Value)
        {
            if (CustomerID == 0)
                throw new Exception("Cannot update attribute for non existing customer");
            return CustomerAttributeDBManager.UpdateCustomerAttribute(CustomerAttributeID, CustomerID, Key, Value);
        }
        #endregion
    }
}
